﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;

namespace Modules.System.Menu
{
    /// <summary>
    /// 主管单位菜单
    ///</summary>
    [TableName("sys_menu")]
    [Description("菜单表")]
    [PrimaryKey("menu_id", AutoIncrement = true)]
    [CacheSetting(true)]
    [Serializable]
    public class SysMenu : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("menu_id")]
        public int MenuId { get; set; }

        /// <summary>
        /// 父菜单ID
        ///</summary>
        [Column("parent_id")]
        public int ParentId { get; set; } = 0;

        /// <summary>
        /// 父节点ID路径
        ///</summary>
        [Column("tree_path")]
        public string TreePath { get; set; }

        /// <summary>
        /// 菜单名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 菜单类型(1:菜单；2:目录；3:外链；4:按钮)
        ///</summary>
        [Column("type")]
        public MenuType? Type { get; set; }

        /// <summary>
        /// 路由路径(浏览器地址栏路径)
        ///</summary>
        [Column("path")]
        public string Path { get; set; }

        /// <summary>
        /// 组件路径(vue页面完整路径，省略.vue后缀)
        ///</summary>
        [Column("component")]
        public string Component { get; set; }

        /// <summary>
        /// 权限标识
        ///</summary>
        [Column("perm")]
        public string Perm { get; set; }

        /// <summary>
        /// 显示状态(1-显示;0-隐藏)
        ///</summary>
        [Column("is_visible")]
        public bool IsVisible { get; set; } = true;

        /// <summary>
        /// 排序
        ///</summary>
        [Column("sort")]
        public int? Sort { get; set; }

        /// <summary>
        /// 菜单图标
        ///</summary>
        [Column("icon")]
        public string Icon { get; set; }

        /// <summary>
        /// 跳转路径
        ///</summary>
        [Column("redirect")]
        public string Redirect { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 更新时间
        ///</summary>
        [Column("update_time")]
        public DateTime? UpdateTime { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return MenuId; } }

        #endregion IEntity 成员
    }
}